import 'dart:convert';

class DiaryListEntity {
  late List<DiaryModel> diarys;
  DiaryListEntity({required this.diarys});
  DiaryListEntity.fromJson(Map<String, dynamic> json) {
    diarys = [
      ...(json['data'] as List? ?? []).map((o) => DiaryModel.fromJson(o))
    ];
  }
}

class DiaryEntity {
  late DiaryModel diaryModel;
  DiaryEntity({required this.diaryModel});
  DiaryEntity.fromJson(Map<String, dynamic> json) {
    if (json['code'] != null) {
      diaryModel = DiaryModel.fromJson(json['data']);
    }
  }
}

class DiaryModel {
  int? diaryId;
  String? title;
  String? content;
  String? city;
  String? location;
  String? weather;
  String? mood;
  String? diaryTime;
  String? createTime;
  String? createTimeSt;
  String? month;
  String? day;
  String? week;
  String? moment;
  String? status;
  bool? isPublish;
  bool? delFlag;

  DiaryModel(
      {this.diaryId,
      this.title,
      this.content,
      this.city,
      this.location,
      this.weather,
      this.mood,
      this.diaryTime,
      this.createTime,
      this.createTimeSt,
      this.month,
      this.day,
      this.week,
      this.moment,
      this.status,
      this.isPublish,
      this.delFlag});

  DiaryModel.fromJson(Map<String, dynamic> json) {
    diaryId = json['diaryId'];
    title = json['title'];
    content = json['content'];
    city = json['city'];
    location = json['location'];
    weather = json['weather'];
    mood = json['mood'];
    diaryTime = json['diaryTime'];
    createTime = json['createTime'];
    createTimeSt = json['createTimeSt'];
    month = json['month'];
    day = json['day'];
    week = json['week'];
    moment = json['moment'];
    status = json['status'];
    isPublish = json['isPublish'];
    delFlag = json['delFlag'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['diaryId'] = diaryId;
    data['title'] = title;
    data['content'] = content;
    data['city'] = city;
    data['location'] = location;
    data['weather'] = weather;
    data['mood'] = mood;
    data['diaryTime'] = diaryTime;
    data['createTime'] = createTime;
    data['createTimeSt'] = createTimeSt;
    data['month'] = month;
    data['day'] = day;
    data['week'] = week;
    data['moment'] = moment;
    data['status'] = status;
    data['isPublish'] = isPublish;
    data['remark'] = delFlag;
    return data;
  }

  @override
  String toString() => jsonEncode(toJson());
}
